package logic

import (
	"cart-master/model"
	"context"

	"cart-master/cartrpc/cartrpc"
	"cart-master/cartrpc/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type ShopShowLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewShopShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShopShowLogic {
	return &ShopShowLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *ShopShowLogic) ShopShow(in *cartrpc.ShopShowRequest) (*cartrpc.ShopShowResponse, error) {
	// todo: add your logic here and delete this line

	var shop model.Shop
	model.DB.Debug().Where("id=?", in.ShopId).First(&shop)
	return &cartrpc.ShopShowResponse{
		Img:   shop.Img,
		Name:  shop.Name,
		Price: float32(shop.Price),
		Num:   int64(shop.Num),
	}, nil
}
